<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<!--
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.
        
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
        
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
        MA 02110-1301, USA.
-->

<html>
	<head>
		<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<meta HTTP-EQUIV="Expires" CONTENT="-1">
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<link type="text/css" href="../../css/jquery-ui/current/jquery-ui.css" rel="stylesheet" />
		<link type="text/css" href="../../css/iframe.css" rel="stylesheet" />
		<script type="text/javascript" src="../../js/jquery.js"></script>
		<script type="text/javascript" src="../../js/jquery-ui.js"></script>
		<script type="text/javascript" src="../../js/jquery.xslt.js"></script>
		<script type="text/javascript" src="../../js/jquery.form.js"></script>
		<script type="text/javascript" src="../../js/iframe.js"></script>
	</head>
	<body style="font-size:12px;">
		<form action="../../../../bin/kernel.py" method="post" id="repaitnote">
		<input type="hidden" name="func" value="setRepairNote" />
			<table>
				<tr>
					<td>Repair Number:</td>
					<td>
						<div id="rnumberdiv">
							R0000000001
						</div>
						<input type="hidden" name="rnumber" value="R0000000001" id="rnumber" />
					</td>
					<td>Dispatch Date:</td>
					<td><input type="text" id="ddate" style="width:200px" name="ddate"></td>
				</tr>
				<tr>
					<td>Serial Number:</td>
					<td>
						<div id="snumberlist"></div>
					</td>
					<td>Dispatch Note:</td>
					<td><input type="text" id="dnote" style="width:200px" name="dnote"></td>
				</tr>
				<tr>
					<td>Repair Date:</td>
					<td><input type="text" id="rdate" style="width:200px" name="rdate"></td>
					<td>Destination:</td>
					<td><div id="destinationlist"></div></td>
				</tr>
				<tr>
					<td>Model:</td>
					<td><div id="mrtmodel"></div></td>
					<td>Special Note:</td>
					<td><input type="text" id="snote" style="width:200px" name="snote"></td>
				</tr>
				<tr>
					<td>Brand:</td>
					<td><input type="text" id="brand" style="width:200px" name="brand"></td>
					<td>Repair Type:</td>
					<td>
						<!--<div id="repairtypelist"></div>-->
						<button type="button" style="width:206px" onclick="javascript:parent.showDialog('RTConsumption');" id="rtbutton" disabled>Select repair type...</button>
					</td>
				</tr>
				<tr>
					<td>Inventary Number:</td>
					<td>
						<input type="text" id="inumber" style="width:200px" name="inumber" disabled="">
					</td>
					<td>Transaction type:</td>
					<td>
						<span id="ttype">Error getCode</span> Consumption Repair
						<input type="hidden" name="transactiontype" value="0" id="transactiontype" />
					</td>
				</tr>
				<tr>
					<td>Customer:</td>
					<td><div id="customerlist"></div></td>
					<td>Other Spare Parts:</td>
					<td>
						<button type="button" style="width:206px" onclick="javascript:parent.showDialog('SPConsumption');" id="spbutton" disabled>Select spare parts...</button>
						<input id="GUID" name="GUID" type="hidden">
					</td>
				</tr>
				<tr>
					<td colspan="4" align="right">
						<button type="submit">Add repair note</button>
					</td>
				</tr>
			</table>
		</form>
		<script language="javascript">
			function updateSPC() {
				var tempTime = new Date();
				var timestamp = tempTime.getTime();
				$("#GUID").attr('value', timestamp);
				parent.dialogData.SPConsumption.getid = timestamp;
				parent.dialogData.SPConsumption.getCustomer = $('#customer').val()
				parent.dialogData.SPConsumption.getModel = $('#imodel').val()
				parent.dialogData.RTConsumption.getid = timestamp;
				parent.dialogData.RTConsumption.getCustomer = $('#customer').val()
				parent.dialogData.RTConsumption.getModel = $('#imodel').val()
			        $('#rtbutton')[0].disabled=false;
			        $('#spbutton')[0].disabled=false;
			}
			
			function updateRepairNumber() {
				$.ajax({
					type: "GET",
					url: "../../../../bin/kernel.py?func=getRepairNumber",
					success: function(msg){
						$('#rnumberdiv').text(msg);
						$('#rnumber').attr('value', msg);						
					}
				});
			}
			
			function updateConsumptionRepairCode() {
				$.ajax({
					type: "GET",
					url: "../../../../bin/kernel.py?func=getConsumptionRepairCode",
					success: function(msg){
						$('#ttype').text(msg);
						$('#transactiontype').attr('value', msg);
					}
				});
			}
			
		
			$(function() {
			        $('#rtbutton')[0].disabled=true;
			        $('#spbutton')[0].disabled=true;
				update('customerlist');
				update('mrtmodel');
				update('destinationlist');
				update('repairtypelist');
				update('snumberlist');
				updateSPC();
				updateRepairNumber();
				updateConsumptionRepairCode();
				parent.editRepairItem = editRepairItem;
				$("#rdate").datepicker({ dateFormat: 'dd-mm-yy' });
				$("#ddate").datepicker({ dateFormat: 'dd-mm-yy' });
				$("#repaitnote").ajaxForm(function() {
			                $('#rtbutton')[0].disabled=true;
			                $('#spbutton')[0].disabled=true;
					alert("Added!!!");
					parent.update_api.update('repairnotetable');
					$('#repaitnote').resetForm();
					updateRepairNumber();
					update('snumberlist');
					updateSPC();
				});
			});
		</script>
	</body>
</html>

